EXPLORATORY DATA ANALYSIS OF PLANETS
PROJECT PROCESS:¶
- IMPORT LIBRARIES
- DATA LOADING
- DATA CLEANING AND PRE-PROCESSING
- EXPLORATORY DATA ANALYSIS (EDA)
IMPORT LIBRARIES:¶
In [1]:
import pandas as pd # Import pandas library for data manipulation and analysis
import numpy as np # Import NumPy library for numerical and array operations
import seaborn as sns # Import Seaborn library for data visualization
import matplotlib.pylab as plt# Import PyLab from Matplotlib for plotting graphs
from mpl_toolkits.mplot3d import Axes3D # for 3D visualization
import warnings # Import Python's built-in warnings module
warnings.filterwarnings('ignore') # Ignore warning messages to keep output clean
DATA LOADING:¶
In [2]:
df = pd.read_csv(r"planets (2).csv")
df
Out[2]:
| Planet | Color | Mass (10^24kg) | Diameter (km) | Density (kg/m^3) | Surface Gravity(m/s^2) | Escape Velocity (km/s) | Rotation Period (hours) | Length of Day (hours) | Distance from Sun (10^6 km) | ... | Orbital Period (days) | Orbital Velocity (km/s) | Orbital Inclination (degrees) | Orbital Eccentricity | Obliquity to Orbit (degrees) | Mean Temperature (C) | Surface Pressure (bars) | Number of Moons | Ring System? | Global Magnetic Field? | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Mercury | Grey | 0.330 | 4879 | 5429 | 3.7 | 4.3 | 1407.6 | 4222.6 | 57.9 | ... | 88 | 47.4 | 7.0 | 0.206 | 0.034 | 167 | 0 | 0 | No | Yes |
| 1 | Venus | Brown and Grey | 4.870 | 12104 | 5243 | 8.9 | 10.4 | -5832.5 | 2802.0 | 108.2 | ... | 224.7 | 35.0 | 3.4 | 0.007 | 177.400 | 464 | 92 | 0 | No | No |
| 2 | Earth | Blue, Brown Green and White | 5.970 | 12756 | 5514 | 9.8 | 11.2 | 23.9 | 24.0 | 149.6 | ... | 365.2 | 29.8 | 0.0 | 0.017 | 23.400 | 15 | 1 | 1 | No | Yes |
| 3 | Mars | Red, Brown and Tan | 0.642 | 6792 | 3934 | 3.7 | 5.0 | 24.6 | 24.7 | 228.0 | ... | 687 | 24.1 | 1.8 | 0.094 | 25.200 | -65 | 0.01 | 2 | No | No |
| 4 | Jupiter | Brown, Orange and Tan, with White cloud stripes | 1898.000 | 142984 | 1326 | 23.1 | 59.5 | 9.9 | 9.9 | 778.5 | ... | 4331 | 13.1 | 1.3 | 0.049 | 3.100 | -110 | Unknown | 79 | Yes | Yes |
| 5 | Saturn | Golden, Brown, and Blue-Grey | 568.000 | 120536 | 687 | 9.0 | 35.5 | 10.7 | 10.7 | 1432.0 | ... | 10,747 | 9.7 | 2.5 | 0.052 | 26.700 | -140 | Unknown | 82 | Yes | Yes |
| 6 | Uranus | Blue-Green | 86.800 | 51118 | 1270 | 8.7 | 21.3 | -17.2 | 17.2 | 2867.0 | ... | 30,589 | 6.8 | 0.8 | 0.047 | 97.800 | -195 | Unknown | 27 | Yes | Yes |
| 7 | Neptune | Blue | 102.000 | 49528 | 1638 | 11.0 | 23.5 | 16.1 | 16.1 | 4515.0 | ... | 59,800 | 5.4 | 1.8 | 0.010 | 28.300 | -200 | Unknown | 14 | Yes | Yes |
8 rows × 22 columns
DATA CLEANING & PRE-PROCESSING:¶
In [3]:
df.shape
Out[3]:
(8, 22)
In [4]:
df.size
Out[4]:
176
In [5]:
df.columns
Out[5]:
Index(['Planet', 'Color', 'Mass (10^24kg)', 'Diameter (km)',
'Density (kg/m^3)', 'Surface Gravity(m/s^2)', 'Escape Velocity (km/s)',
'Rotation Period (hours)', 'Length of Day (hours)',
'Distance from Sun (10^6 km)', 'Perihelion (10^6 km)',
'Aphelion (10^6 km)', 'Orbital Period (days)',
'Orbital Velocity (km/s)', 'Orbital Inclination (degrees)',
'Orbital Eccentricity', 'Obliquity to Orbit (degrees)',
'Mean Temperature (C)', 'Surface Pressure (bars)', 'Number of Moons',
'Ring System?', 'Global Magnetic Field?'],
dtype='object')
In [6]:
df.isnull().sum()
Out[6]:
Planet 0 Color 0 Mass (10^24kg) 0 Diameter (km) 0 Density (kg/m^3) 0 Surface Gravity(m/s^2) 0 Escape Velocity (km/s) 0 Rotation Period (hours) 0 Length of Day (hours) 0 Distance from Sun (10^6 km) 0 Perihelion (10^6 km) 0 Aphelion (10^6 km) 0 Orbital Period (days) 0 Orbital Velocity (km/s) 0 Orbital Inclination (degrees) 0 Orbital Eccentricity 0 Obliquity to Orbit (degrees) 0 Mean Temperature (C) 0 Surface Pressure (bars) 0 Number of Moons 0 Ring System? 0 Global Magnetic Field? 0 dtype: int64
In [7]:
df['Orbital Period (days)']=df['Orbital Period (days)'].str.replace(',','')
df['Orbital Period (days)']=df['Orbital Period (days)'].astype('float')
In [8]:
df.head(10)
Out[8]:
| Planet | Color | Mass (10^24kg) | Diameter (km) | Density (kg/m^3) | Surface Gravity(m/s^2) | Escape Velocity (km/s) | Rotation Period (hours) | Length of Day (hours) | Distance from Sun (10^6 km) | ... | Orbital Period (days) | Orbital Velocity (km/s) | Orbital Inclination (degrees) | Orbital Eccentricity | Obliquity to Orbit (degrees) | Mean Temperature (C) | Surface Pressure (bars) | Number of Moons | Ring System? | Global Magnetic Field? | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Mercury | Grey | 0.330 | 4879 | 5429 | 3.7 | 4.3 | 1407.6 | 4222.6 | 57.9 | ... | 88.0 | 47.4 | 7.0 | 0.206 | 0.034 | 167 | 0 | 0 | No | Yes |
| 1 | Venus | Brown and Grey | 4.870 | 12104 | 5243 | 8.9 | 10.4 | -5832.5 | 2802.0 | 108.2 | ... | 224.7 | 35.0 | 3.4 | 0.007 | 177.400 | 464 | 92 | 0 | No | No |
| 2 | Earth | Blue, Brown Green and White | 5.970 | 12756 | 5514 | 9.8 | 11.2 | 23.9 | 24.0 | 149.6 | ... | 365.2 | 29.8 | 0.0 | 0.017 | 23.400 | 15 | 1 | 1 | No | Yes |
| 3 | Mars | Red, Brown and Tan | 0.642 | 6792 | 3934 | 3.7 | 5.0 | 24.6 | 24.7 | 228.0 | ... | 687.0 | 24.1 | 1.8 | 0.094 | 25.200 | -65 | 0.01 | 2 | No | No |
| 4 | Jupiter | Brown, Orange and Tan, with White cloud stripes | 1898.000 | 142984 | 1326 | 23.1 | 59.5 | 9.9 | 9.9 | 778.5 | ... | 4331.0 | 13.1 | 1.3 | 0.049 | 3.100 | -110 | Unknown | 79 | Yes | Yes |
| 5 | Saturn | Golden, Brown, and Blue-Grey | 568.000 | 120536 | 687 | 9.0 | 35.5 | 10.7 | 10.7 | 1432.0 | ... | 10747.0 | 9.7 | 2.5 | 0.052 | 26.700 | -140 | Unknown | 82 | Yes | Yes |
| 6 | Uranus | Blue-Green | 86.800 | 51118 | 1270 | 8.7 | 21.3 | -17.2 | 17.2 | 2867.0 | ... | 30589.0 | 6.8 | 0.8 | 0.047 | 97.800 | -195 | Unknown | 27 | Yes | Yes |
| 7 | Neptune | Blue | 102.000 | 49528 | 1638 | 11.0 | 23.5 | 16.1 | 16.1 | 4515.0 | ... | 59800.0 | 5.4 | 1.8 | 0.010 | 28.300 | -200 | Unknown | 14 | Yes | Yes |
8 rows × 22 columns
In [9]:
df["Orbital Period (days)"]
Out[9]:
0 88.0 1 224.7 2 365.2 3 687.0 4 4331.0 5 10747.0 6 30589.0 7 59800.0 Name: Orbital Period (days), dtype: float64
CORRECTING ANORMALLY IN DATA SET:¶
In [10]:
df.rename(columns={'Orbital Period (days)':'Orbital_Period'},inplace=True)
df
Out[10]:
| Planet | Color | Mass (10^24kg) | Diameter (km) | Density (kg/m^3) | Surface Gravity(m/s^2) | Escape Velocity (km/s) | Rotation Period (hours) | Length of Day (hours) | Distance from Sun (10^6 km) | ... | Orbital_Period | Orbital Velocity (km/s) | Orbital Inclination (degrees) | Orbital Eccentricity | Obliquity to Orbit (degrees) | Mean Temperature (C) | Surface Pressure (bars) | Number of Moons | Ring System? | Global Magnetic Field? | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Mercury | Grey | 0.330 | 4879 | 5429 | 3.7 | 4.3 | 1407.6 | 4222.6 | 57.9 | ... | 88.0 | 47.4 | 7.0 | 0.206 | 0.034 | 167 | 0 | 0 | No | Yes |
| 1 | Venus | Brown and Grey | 4.870 | 12104 | 5243 | 8.9 | 10.4 | -5832.5 | 2802.0 | 108.2 | ... | 224.7 | 35.0 | 3.4 | 0.007 | 177.400 | 464 | 92 | 0 | No | No |
| 2 | Earth | Blue, Brown Green and White | 5.970 | 12756 | 5514 | 9.8 | 11.2 | 23.9 | 24.0 | 149.6 | ... | 365.2 | 29.8 | 0.0 | 0.017 | 23.400 | 15 | 1 | 1 | No | Yes |
| 3 | Mars | Red, Brown and Tan | 0.642 | 6792 | 3934 | 3.7 | 5.0 | 24.6 | 24.7 | 228.0 | ... | 687.0 | 24.1 | 1.8 | 0.094 | 25.200 | -65 | 0.01 | 2 | No | No |
| 4 | Jupiter | Brown, Orange and Tan, with White cloud stripes | 1898.000 | 142984 | 1326 | 23.1 | 59.5 | 9.9 | 9.9 | 778.5 | ... | 4331.0 | 13.1 | 1.3 | 0.049 | 3.100 | -110 | Unknown | 79 | Yes | Yes |
| 5 | Saturn | Golden, Brown, and Blue-Grey | 568.000 | 120536 | 687 | 9.0 | 35.5 | 10.7 | 10.7 | 1432.0 | ... | 10747.0 | 9.7 | 2.5 | 0.052 | 26.700 | -140 | Unknown | 82 | Yes | Yes |
| 6 | Uranus | Blue-Green | 86.800 | 51118 | 1270 | 8.7 | 21.3 | -17.2 | 17.2 | 2867.0 | ... | 30589.0 | 6.8 | 0.8 | 0.047 | 97.800 | -195 | Unknown | 27 | Yes | Yes |
| 7 | Neptune | Blue | 102.000 | 49528 | 1638 | 11.0 | 23.5 | 16.1 | 16.1 | 4515.0 | ... | 59800.0 | 5.4 | 1.8 | 0.010 | 28.300 | -200 | Unknown | 14 | Yes | Yes |
8 rows × 22 columns
In [11]:
#replace incorect values with correct values
df['Length of Day (hours)'].replace({4222.6:1407.6,2802.0:5832.5},inplace=True)
#save the updated data set to a new file or overwrite the existing one
df.to_csv('planets_updated.csv',index=False)
df.head()
Out[11]:
| Planet | Color | Mass (10^24kg) | Diameter (km) | Density (kg/m^3) | Surface Gravity(m/s^2) | Escape Velocity (km/s) | Rotation Period (hours) | Length of Day (hours) | Distance from Sun (10^6 km) | ... | Orbital_Period | Orbital Velocity (km/s) | Orbital Inclination (degrees) | Orbital Eccentricity | Obliquity to Orbit (degrees) | Mean Temperature (C) | Surface Pressure (bars) | Number of Moons | Ring System? | Global Magnetic Field? | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Mercury | Grey | 0.330 | 4879 | 5429 | 3.7 | 4.3 | 1407.6 | 1407.6 | 57.9 | ... | 88.0 | 47.4 | 7.0 | 0.206 | 0.034 | 167 | 0 | 0 | No | Yes |
| 1 | Venus | Brown and Grey | 4.870 | 12104 | 5243 | 8.9 | 10.4 | -5832.5 | 5832.5 | 108.2 | ... | 224.7 | 35.0 | 3.4 | 0.007 | 177.400 | 464 | 92 | 0 | No | No |
| 2 | Earth | Blue, Brown Green and White | 5.970 | 12756 | 5514 | 9.8 | 11.2 | 23.9 | 24.0 | 149.6 | ... | 365.2 | 29.8 | 0.0 | 0.017 | 23.400 | 15 | 1 | 1 | No | Yes |
| 3 | Mars | Red, Brown and Tan | 0.642 | 6792 | 3934 | 3.7 | 5.0 | 24.6 | 24.7 | 228.0 | ... | 687.0 | 24.1 | 1.8 | 0.094 | 25.200 | -65 | 0.01 | 2 | No | No |
| 4 | Jupiter | Brown, Orange and Tan, with White cloud stripes | 1898.000 | 142984 | 1326 | 23.1 | 59.5 | 9.9 | 9.9 | 778.5 | ... | 4331.0 | 13.1 | 1.3 | 0.049 | 3.100 | -110 | Unknown | 79 | Yes | Yes |
5 rows × 22 columns
EXPLORATORY DATA ANALYSIS:¶
In [12]:
# Mass vs Diameter
plt.figure(figsize=(10, 6))
plt.scatter(df['Mass (10^24kg)'], df['Diameter (km)'], s=100, alpha=0.7)
plt.xlabel('Mass (10^24 kg)')
plt.ylabel('Diameter (km)')
plt.title('Mass vs Diameter Relationship')
for i, planet in enumerate(df['Planet']):
plt.annotate(planet, (df['Mass (10^24kg)'][i], df['Diameter (km)'][i]),
xytext=(5, 5), textcoords='offset points')
plt.grid(True, alpha=0.3)
plt.show()
* The relationship is not a smooth, linear trend across all planets, but rather reveals a fundamental division in the solar system between the small, rocky planets and the massive, gaseous/icy giants.¶
In [13]:
# Prepare data for box plots
box_data = df[['Mass (10^24kg)', 'Diameter (km)', 'Density (kg/m^3)',
'Surface Gravity(m/s^2)', 'Mean Temperature (C)']]
plt.figure(figsize=(12, 8))
box_data.boxplot()
plt.title('Distribution of Planetary Characteristics')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
* Domination by Diameter and Mass: Due to their large magnitudes (Diameter up to 142,984 km and Mass up to 1,898×10 24kg), the box plots for these two features overshadow all others.¶
* Squashed Features: The box plots for Density, Surface Gravity, and Mean Temperature (whose maximum values are only 5514, 23.1, and 464, respectively) appear as flat lines near the baseline.¶
* Outlier Confirmation: The immense size of the Diameter and Mass boxplots confirms the Gas Giants (Jupiter and Saturn) are massive outliers in these specific properties compared to the other planets.¶
In [14]:
# Number of moons distribution
plt.figure(figsize=(10, 8))
plt.pie(df['Number of Moons'], labels=df['Planet'], autopct='%1.1f%%',
startangle=90)
plt.title('Distribution of Moons Among Planets')
plt.axis('equal')
plt.show()
* Saturn (82 moons) and Jupiter (79 moons) account for the vast majority of the total known moons, consuming the largest slices of the pie.¶
* The terrestrial planets (Mercury, Venus, Earth, Mars) and the ice giants (Uranus, Neptune) collectively represent a small fraction of the total count. Mercury and Venus have 0 moons, and therefore contribute 0% to the total.¶
In [15]:
# Violin plot for gravity
plt.figure(figsize=(10, 6))
sns.violinplot(data=df, y='Surface Gravity(m/s^2)')
plt.title('Distribution of Surface Gravity')
plt.show()
* Primary Cluster (Low Gravity): The distribution is heavily concentrated in the lower gravity range (approximately 3.7 to 11 m/s 2). This cluster represents the smaller Terrestrial Planets and the less dense Ice Giants and Saturn.¶
* Extreme Outlier (High Gravity): The long upper tail clearly identifies Jupiter as a massive outlier with a surface gravity of 23.1 m/s 2. Jupiter's gravity is far greater than any other planet, creating a separate high-density region (or a very long tail) that dominates the total range.¶
In [16]:
# 3D Scatter plot (if you have 3D plotting capability)
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111, projection='3d')
scatter = ax.scatter(df['Mass (10^24kg)'], df['Diameter (km)'],
df['Distance from Sun (10^6 km)'],
c=df['Mean Temperature (C)'], s=df['Surface Gravity(m/s^2)']*20,
cmap='viridis', alpha=0.7)
ax.set_xlabel('Mass (10^24 kg)')
ax.set_ylabel('Diameter (km)')
ax.set_zlabel('Distance from Sun (10^6 km)')
plt.colorbar(scatter, label='Mean Temperature (C)')
plt.title('3D Planetary Characteristics')
plt.show()
The plot reveals an extreme and fundamental bimodal distribution, creating two distinct clusters that define the solar system's planet classification:¶
1.Inner Rocky Cluster (Near Origin): This cluster is tightly grouped near the origin (low X, Y, and Z values). These points are characterized by:¶
* Low Mass and Diameter.¶
* High Temperature (hot colors), due to their proximity to the Sun.¶
* Small size (lower surface gravity) relative¶
In [17]:
#largest planet by size
plt.figure(figsize=(12,6))
sns.barplot(x=df['Planet'],y=df['Diameter (km)'],palette='husl')
plt.ylabel('Diameter (km)')
plt.xlabel('Planet')
plt.title('LARGEST PLANETS')
plt.xticks(rotation=75)
plt.show()
In [18]:
# Mass distribution among planets
plt.figure(figsize=(10, 8))
plt.pie(df['Mass (10^24kg)'], labels=df['Planet'], autopct='%1.1f%%',
startangle=90)
plt.title('Mass Distribution Among Planets')
plt.axis('equal')
plt.show()
* The mass distribution is extremely dominated by a single planet, Jupiter. Jupiter's mass (1898×10 24 kg) is overwhelmingly larger than all other planets combined, resulting in its slice consuming the vast majority of the pie chart. Saturn is the second largest contributor, but still significantly smaller than Jupiter. The four inner, rocky planets (Mercury, Venus, Earth, Mars) and the two ice giants (Uranus, Neptune) collectively represent a tiny fraction of the total solar system planetary mass.¶
In [19]:
#which is the largest planet by mass
plt.figure(figsize=(12,6))
sns.barplot(x=df['Planet'],y=df['Mass (10^24kg)'],palette='husl')
plt.xlabel('Planet')
plt.ylabel('Mass (10^24kg)')
plt.title('largest planet by mass')
plt.xticks(rotation=65)
plt.show()
* jupiter has the largest mass and mercury has smallest mass¶
In [20]:
# which planet nearest to sun
plt.figure(figsize=(12,8))
sns.barplot(x=df['Planet'],y=df['Distance from Sun (10^6 km)'],palette='husl')
plt.title('nearest planet to sun')
plt.xlabel('Planet')
plt.ylabel('Distance from Sun (10^6 km)')
plt.xticks(rotation=45)
plt.show()
* neptune is farest to sun while mercury is nearest to sun¶
In [21]:
#which planet the length of days longest
plt.figure(figsize=(12,9))
sns.barplot(x=df['Planet'],y=df['Length of Day (hours)'],palette='husl')
plt.title('length of days longest')
plt.xlabel('Planet')
plt.ylabel('Length of Day (hours)')
plt.xticks(rotation=78)
plt.show()
* since the length of the day on venus is geater than on mercury so there is anomally in the data set should be corrected so we correct it¶
In [22]:
#graph after correction of anomali
plt.figure(figsize=(12,9))
sns.barplot(x=df['Planet'],y=df['Length of Day (hours)'],palette='husl')
plt.title('length of days longest')
plt.xlabel('Planet')
plt.ylabel('Length of Day (hours)')
plt.xticks(rotation=78)
plt.show()
* Venus has the longest day of any planet in the solar system. This is because Venus takes 243 Earth days to rotate once on its axis, while Earth takes 24 hours. Venus has the slowest rotation of any planet, Venusian day is longer than a Venusian year, which is only about 224 Earth-days long. Many scientists believe that the long days are a result of the sun's strong pull on the planet.¶
In [23]:
#which planet has the solar system as clock wise rotaion
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Rotation Period (hours)'],palette='husl')
plt.title('the solar system as clock wise rotaion')
plt.xlabel('Planet')
plt.ylabel('Rotation Period (hours)')
plt.show()
* Most planets rotate on their axes in an anticlockwise direction, but Venus rotates clockwise in retrograde rotation (which means it rotates in the opposite direction to its orbital direction. This means that Venus rotates "backwards" or "upside down" in the negative z-direction).¶
* Venus is the only planet in our solar system, aside from Uranus, that rotates clockwise. Scientists don't have a definitive answer as to why, but there are many theories:¶
In [24]:
#which planet has the greatest density
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Density (kg/m^3)'],palette='husl')
plt.title('gratest density')
plt.xlabel('Planet')
plt.ylabel('Density (kg/m^3)')
plt.show()
* Earth is the densest planet in our solar system, with an average density of 5,514 kg/m³. Mercury is the second densest planet, with a mean density of 5,429 kg/m³.¶
* In general, terrestrial (rocky) planets are denser than the gas and ice giants. The four inner terrestrial planets are dense compared to the four outer planets because the inner planets are made up mainly of dense, solid rock, while the outer planets are composed primarily of gas.¶
* Saturn, the least dense planet in the Solar System on the other hand, has a density lower than that of water.¶
In [25]:
#which planet has the long year
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Orbital_Period'],palette='husl')
plt.title('planet has the long year')
plt.xlabel('Planet')
plt.ylabel('Orbital_Period')
plt.show()
* The closest planet to the sun, Mercury has a shorter orbital period of 88 days. The sun's stronger gravitational pull on Mercury makes it move faster, and its shorter orbital path also contributes to its shorter orbital period.¶
* Neptune has the longest orbital period of any planet in the Solar System. As such, a year on Neptune is the longest of any planet, lasting the equivalent of 164.8 years (or 60,182 Earth days). Planets that are farther from the sun have longer paths and travel slower because the sun's gravitational pull is weaker.¶
In [26]:
#which planet has the longest velocity
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Escape Velocity (km/s)'],palette='husl')
plt.title('planet has the longest velocity')
plt.xlabel('Planet')
plt.ylabel('Escape Velocity (km/s)')
plt.show()
* Escape velocity is the minimum velocity that a body must attain to escape a gravitation field completely.¶
* Escape velocity depends on the mass and radius of a celestial body. The gravitational force between two objects depends on their combined mass.¶
* Jupiter has the highest escape velocity among planets. This is because Jupiter has the highest mass. The escape velocity of Jupiter is 59.5 km/s.¶
In [27]:
#which planet has the highest surface gravity
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Surface Gravity(m/s^2)'],palette='husl')
plt.title('planet has the highest surface gravity')
plt.xlabel('Planet')
plt.ylabel('Surface Gravity(m/s^2)')
plt.show()
* Surface gravity is the gravitational force experienced at the surface of an astronomical object, including the effects of rotation. It is measured in units of acceleration, such as meters per second squared (m/s²). Surface gravity is also expressed as a multiple of the Earth's standard surface gravity, which is 9.80665 m/s²¶
* The surface gravity of a planet is determined by both its mass and radius. The equation for gravitational force states that the force of gravity decreases with the square of the distance from the center of mass.¶
* Jupiter's surface gravity is 2.4 times greater than Earth's because Jupiter is more massive than Earth. However, Jupiter's surface gravity is only 2.5 times greater than Earth's because Jupiter's radius is much larger than Earth's. This means that a point on Jupiter's surface is farther from its center of mass and experiences a weaker gravitational pull. That's why Jupiter has highest Escape velocity.¶
In [28]:
# Pairplot for multiple relationships
sns.pairplot(df[['Mass (10^24kg)', 'Diameter (km)', 'Density (kg/m^3)',
'Surface Gravity(m/s^2)', 'Mean Temperature (C)']])
plt.suptitle('Pairwise Relationships of Planetary Characteristics', y=1.02)
plt.show()
* Mass & Diameter/Gravity Relationship: There will likely be a strong positive correlation between Mass and Diameter, and between Mass and Surface Gravity (especially when considering the gas giants like Jupiter and Saturn).¶
* Density Disparity: The distributions will visually confirm the existence of two distinct groups: the dense, low-mass rocky inner planets and the low-density, high-mass gas/ice giants.¶
* Temperature Trend: Mean Temperature will likely show a rough inverse correlation with mass/diameter/gravity, as the smaller, closer-to-the-Sun inner planets (like Mercury and Venus) have higher temperatures than the massive but distant outer planets.¶
In [29]:
#which is the hottest planet
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Mean Temperature (C)'],palette='husl')
plt.title('the hottest planet')
plt.xlabel('Planet')
plt.ylabel('Mean Temperature (C)')
plt.show()
* Venus is the hottest planet in our solar system because of its thick atmosphere, which traps heat in a runaway greenhouse effect. The surface of Venus is about 465°C (864°F) hot.¶
* Venus is the second planet from the Sun and is sometimes called Earth's twin because it's similar in size and structure to Earth. However, Venus has a thick atmosphere made up of greenhouse gases like carbon dioxide, nitrogen, and sulfuric acid clouds. When sunlight passes through the atmosphere, it heats up the surface and is blocked by the atmosphere, causing the heat to build up and trap in a greenhouse effect. Although mercury is the closest to the sun but it has no atmosphere to trap the heat received from the sun.¶
* Planetary surface temperatures tend to get colder the farther a planet is from the Sun.¶
In [30]:
#which plnet has the most number of moons
plt.figure(figsize=(12,7))
sns.barplot(x=df['Planet'],y=df['Number of Moons'],palette='husl')
plt.title('plnet has the most number of moons')
plt.xlabel('Planet')
plt.ylabel('Number of Moons')
plt.show()
* Saturn has the most moons of any planet in our solar system, with 82, while Jupiter has 79.¶
In [31]:
# Orbital eccentricity
plt.figure(figsize=(10, 6))
plt.bar(df['Planet'], df['Orbital Eccentricity'], color='teal')
plt.title('Orbital Eccentricity of Planets')
plt.xlabel('Planet')
plt.ylabel('Orbital Eccentricity')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
* high Orbital eccentricity is mercury¶
In [32]:
# Ring system analysis
ring_counts = df['Ring System?'].value_counts()
plt.figure(figsize=(8, 6))
plt.pie(ring_counts.values, labels=ring_counts.index, autopct='%1.1f%%',
colors=['lightblue', 'lightcoral'])
plt.title('Planets with Ring Systems')
plt.axis('equal')
plt.show()
* The presence of a ring system is equally distributed among the planets in this solar system dataset (likely the eight major planets).¶
In [33]:
# Orbital velocity vs distance
plt.figure(figsize=(10, 6))
plt.plot(df['Planet'], df['Orbital Velocity (km/s)'], marker='o', label='Orbital Velocity')
plt.plot(df['Planet'], df['Escape Velocity (km/s)'], marker='s', label='Escape Velocity')
plt.title('Orbital vs Escape Velocity')
plt.xlabel('Planet')
plt.ylabel('Velocity (km/s)')
plt.xticks(rotation=45)
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
* Orbital velocity declines sharply with distance from the Sun, but Escape Velocity dramatically dominates for the high-mass outer planets.¶
In [34]:
# Magnetic field analysis
mag_counts = df['Global Magnetic Field?'].value_counts()
plt.figure(figsize=(8, 6))
plt.bar(mag_counts.index, mag_counts.values, color=['skyblue', 'salmon'])
plt.title('Planets with Global Magnetic Fields')
plt.ylabel('Count')
plt.show()